import request from '../utils/request';

export const courseApi = {
    // 课程分页
    getCoursePage: (data) => request({
        url: '/course/course/page',
        method: 'post',
        data,
    }),
    // 新增课程
    addCourse: (data) => request({
        url: '/course/course',
        method: 'post',
        data,
    }),
    // 获取课程详情
    getCourseDetail: (id) => request({
        url: `/course/course/${id}`,
        method: 'get',
    }),
    // 更新课程
    updateCourse: (data) => request({
        url: '/course/course',
        method: 'put',
        data,
    }),
    // 删除课程
    deleteCourse: (id) => request({
        url: `/course/course/${id}`,
        method: 'delete',
    }),

    // 获取课程详情章节
    getChapters: (courseId) => request({
        url: `/course/chapter/${courseId}`,
        method: 'get',
    }),
    // 批量保存/更新章节
    saveOrUpdateChapters: (courseId, details) => request({
        url: `/course/chapter/${courseId}`,
        method: 'post',
        data: details,
    }),
    // 删除单个章节
    deleteChapter: (chapterId) => request({
        url: `/course/chapter/${chapterId}`,
        method: 'delete',
    }),
    // 新增单个章节
    addChapter: (data) => request({
        url: "/course/chapter",
        method: 'post',
        data,
    }),
    // 修改单个章节
    updateChapter: (data) => request({
        url: `/course/chapter`,
        method: 'put',
        data,
    }),

}; 